using AnQinFrameWorkAPI.Entity.Finance.DTO.FinanceCategory;
using AnQinFrameWorkAPI.Entity.Finance.View.FinanceCategory;
using AnQinFrameWorkAPI.Service.Finance;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Finance;

/// <summary>
///     财务分类API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Finance")]
public class FinanceCategoryController : ControllerBase
{
    //业务接口
    private readonly FinanceCategoryService _financeCategoryService;

    //构造注入
    public FinanceCategoryController(FinanceCategoryService financeCategoryService)
    {
        _financeCategoryService = financeCategoryService;
    }

    /// <summary>
    ///     获取财务分类列表
    /// </summary>
    [ProducesResponseType(typeof(FinanceCategoryView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetFinanceCategoryList([FromQuery] FinanceCategorySearchDTO financeCategorySearchDTO)
    {
        var response = await _financeCategoryService.GetFinanceCategoryList(financeCategorySearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增财务分类
    /// </summary>
    [HttpPost]
    public async Task<IActionResult> AddFinanceCategory([FromBody] FinanceCategoryAddDTO financeCategoryAddDTO)
    {
        var response = await _financeCategoryService.AddFinanceCategory(financeCategoryAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     编辑财务分类
    /// </summary>
    [HttpPut]
    public async Task<IActionResult> PutFinanceCategory([FromBody] FinanceCategoryUpdateDTO financeCategoryUpdateDTO)
    {
        var response = await _financeCategoryService.PutFinanceCategory(financeCategoryUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除财务分类
    /// </summary>
    [HttpDelete]
    public async Task<IActionResult> DeleteFinanceCategory([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _financeCategoryService.DeleteFinanceCategory(deleteDTO);
        return StatusCode(response.Status, response);
    }
}